<template>
	<view class="box">
		<view class="tips" v-if="isStatus==1">
			<view class="tips-title">
				<image class="myImg" src="@/static/images/index/success.png"></image>
				<view class="title1">审核通过</view>
			</view>
			<view>该随手拍审核通过</view>
		</view>
		<view class="tips" v-else>
			<view class="tips-title">
				<image class="myImg" src="@/static/images/index/error.png"></image>
				<view class="title2">审核未通过</view>
			</view>
			<view>该随手拍审核未通过</view>
		</view>
		<view class="main-list">
			<view class="item-list" style="border-bottom: 2rpx solid #F5F5F5;">
				<view class="text">
					隐患位置
				</view>
				<view class="right1 ziti" style="text-align: end;">{{dataForm.dangerSite}}</view>
			</view>
			<view class="item-list" style="border-bottom: 2rpx solid #F5F5F5;" v-if="isStatus==1">
				<view class="text">隐患等级</view>
				<view class="right2 ziti" style="text-align: end;">
					<view :class="[dataForm.dangerLevel == 1?'level-small':'level-big']">
						{{ dataForm.dangerLevel == 1?'一般隐患':'重大隐患' }}
					</view>
				</view>
			</view>
			<view class="item-list text">隐患照片</view>
			<view class="item-list" style="padding-top: 0;padding-bottom: 16rpx;border-bottom: 2rpx solid #F5F5F5;">
				<view class="imgBox" v-if="fileList1.length">
					<view class="img" v-for="v in imgList">
						<image @tap="previewImage(v,imgList)" :src="v"></image>
					</view>
					<video class="video" v-for="v in videoList" :src="v"></video>
				</view>
				<view v-else>无</view>
			</view>
			<view class="line8"></view>
			<view class="item-list text" style="padding-bottom: 16rpx;">隐患描述</view>
			<view class="item-list ziti" style="padding-top: 0;padding-bottom: 16rpx;border-bottom: 2rpx solid #F5F5F5;">{{dataForm.dangerDesc}}</view>
			<view class="item-list" v-if="isStatus==1" style="border-bottom: 2rpx solid #F5F5F5;">
				<view class="text">
					隐患形成原因
				</view>
				<view class="right-text ziti">{{dangerReasonData[dataForm.dangerReason - 1]?dangerReasonData[dataForm.dangerReason - 1]:'无'}}</view>
			</view>
			<view v-if="isStatus==1" class="item-list text">整改意见</view>
			<view v-if="isStatus==1" class="item-list ziti" style="padding-top: 0;padding-bottom: 16rpx;border-bottom: 2rpx solid #F5F5F5;">{{dataForm.suggestion}}</view>
			<!-- <view class="text">
					整改意见
				</view>
				<view class="right-text">{{dataForm.suggestion}}</view> -->
			<template v-if="isStatus==1">
				<view class="item-list" style="border-bottom: 2rpx solid #F5F5F5;"><span class="text">整改部门</span><span
						class="ziti">{{dataForm.rectifyDeptName}}</span></view>
				<view class="item-list" style="border-bottom: 2rpx solid #F5F5F5;"><span class="text">整改人</span><span class="ziti">{{dataForm.rectifyName}}</span>
				</view>
			</template>
			<view class="item-list" style="border-bottom: 2rpx solid #F5F5F5;"><span class="text">{{isStatus==1?'整改时限':'提交时间'}}</span><span
					class="ziti">{{isStatus==1? dataForm.limitDate : dataForm.createTime}}</span>
			</view>
			<view class="line8" v-if="isStatus==1"></view>
			<template v-if="isStatus==1">
				<view class="item-list" style="border-bottom: 2rpx solid #F5F5F5;"><span class="text">提交时间</span><span class="ziti">{{dataForm.createTime}}</span>
				</view>
				<view class="item-list" style="border-bottom: 2rpx solid #F5F5F5;"><span class="text">审核时间</span><span class="ziti">{{dataForm.auditTime}}</span>
				</view>
				<view class="item-list" style="border-bottom: 2rpx solid #F5F5F5;"><span class="text">审核人</span><span class="ziti">{{dataForm.auditName}}</span>
				</view>
			</template>
			<template v-else>
				<view class="item-list text" style="padding-bottom: 16rpx;">未通过原因</view>
				<view class="item-list ziti" style="border-bottom: 2rpx solid #F5F5F5;padding-top: 0;">{{dataForm.reason}}</view>
				<!-- <view class="item-list"><span class="text">未通过原因</span><span>{{dataForm.reason}}</span></view> -->
				<view class="item-list" style="border-bottom: 2rpx solid #F5F5F5;"><span class="text">审核人</span><span class="ziti">{{dataForm.auditName}}</span>
				</view>
				<view class="item-list" style="border-bottom: 2rpx solid #F5F5F5;"><span class="text">审核时间</span><span class="ziti">{{dataForm.auditTime}}</span>
				</view>
			</template>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isStatus: 1, // 2未通过 1通过
				fileList1: [],
				imgList: [],
				videoList: [],
				sourceType: ['album', 'camera'],
				randomId: '',
				dataForm: {},
				dangerReasonData: ['人的不安全行为', '物的不安全状态', '管理缺陷', '环境与场所', '其他'],
			}
		},
		onLoad(options) {
			this.isStatus = options.isStatus
			this.randomId = options.randomId
			this.initData()
		},
		methods: {
			initData() {
				uni.$u.http.get(`/check/mobile/appSmallTake/smallTakeDetail/${this.randomId}`).then(res => {
					if (res.code == 0) {
						this.dataForm = res.data
						if (res.data.dangerPhoto != '') {
							// 图片回显
							let arr = []
							res.data.dangerPhoto.split(',').map(item => {
								let dd = {
									url: item
								}
								arr.push(dd);
							})
							this.fileList1 = arr
							this.fileList1.forEach(item => {
								let str = item.url.split('?')[0]
								if (str.substring(str.length - 3, str.length) == 'mp4') {
									this.videoList.push(item.url)
								} else {
									this.imgList.push(item.url)
								}
							})
						}
					}
				}).catch(err => {})
			},
			//预览图片
			previewImage: function(e, s) {
				let imgList = []
				if (s.pictures) {
					imgList = this.getpictureList(s.pictures)
				} else {
					imgList = s
				}
				uni.previewImage({
					current: e,
					urls: imgList,
				});
			},
			//处理图片
			getpictureList(pictureinfo) {
				if (pictureinfo) {
					var splitAdd = pictureinfo.split(",");
					var imgList = []
					for (let i = 0; i < splitAdd.length; i++) {
						let iOrV = splitAdd[i].split("?")[0].split(".")
						let iOrVL = splitAdd[i].split("?")[0].split(".").length - 1
						if (iOrV[iOrVL] != 'mp4') {
							imgList.push(splitAdd[i])
						}
					}
					return imgList
				} else {
					return []
				}
			}
		}
	}
</script>

<style lang="scss">
	.box {
		.tips {
			font-size: 28rpx;
			color: #A6A6A6;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			padding: 32rpx 0;
			background: #F5F5F5;



			.tips-title {
				display: flex;
				justify-content: center;
				align-items: center;

				.myImg {
					width: 24px;
					height: 24px;
					margin-right: 8rpx;
				}

				.title1 {
					font-size: 16px;
					font-weight: 400;
					color: #02AD82;
					margin: 16rpx 0 8rpx;
				}

				.title2 {
					font-size: 16px;
					font-weight: 400;
					color: #FF4D4D;
					margin: 16rpx 0 8rpx;
				}
			}


		}

		.main-list {
			// padding: 0 32rpx;
			background-color: #fff;
			font-size: 34rpx;

			.item-list {
				padding: 32rpx;
				// border-bottom: 2rpx solid #f5f5f5;
				display: flex;
				justify-content: space-between;
				word-wrap: break-word;
				word-break: break-all;

				.right1 {
					width: 70%;
					word-wrap: break-word;
					word-break: break-all;
				}
				.right2{
					word-wrap: break-word;
					word-break: break-all;
					
					.level-small{
							border-radius: 8rpx;
							font-size: 24rpx;
							color: #FC770A;
							padding: 8rpx 16rpx;
							background-color: rgba(252, 119, 10, 0.2);
					}
					.level-big{
						border-radius: 8rpx;
						font-size: 24rpx;
						color: #FF4D4D;
						padding: 8rpx 16rpx;
						background-color: rgba(255, 77, 77, 0.2);
					}
				}
			}
			
			// .item-list:nth-last-child(15) {
			// 	border-bottom: none;
			// }

			// .item-list:nth-last-child(14) {
			// 	border-bottom: none;
			// }

			// .item-list:nth-last-child(12) {
			// 	border-bottom: none;
			// }
			
			// .item-list:nth-last-child(9) {
			// 	border-bottom: none;
			// }

			.text {
				color: #666666;
				font-size: 16px;
				font-weight: 400;
			}

			.item-upload {
				border-bottom: none;
			}
		}
	}

	.imgBox {
		display: flex;

		.img {
			width: 27vw;
			height: 27vw;
			margin-bottom: 4vw;
			margin-right: 4vw;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.video {
			width: 27vw;
			height: 27vw;
			margin-bottom: 4vw;
			margin-right: 4vw;
		}
	}

	.ziti {
		font-size: 16px;
		color: #2b2b2b;
		font-weight: 400;
	}
</style>